package test.cor.boundaries;

import java.io.IOException;
import java.util.Scanner;

import functionality.Network;
import test.cor.command.ICommand;
import test.cor.command.TestCommand;
import test.cor.controller.*;

public class Menu {
	CommandController cC;
	
	public Menu(CommandController cC){
		this.cC = cC;
		
		//Prints out console menu
		Scanner sc = new Scanner(System.in);
		
		try {
			System.out.println("Enter the IP you want to connect to: ");
			String tempIP = sc.nextLine();
			System.out.println("Enter the port you want to connect to: ");
			int tempInt = sc.nextInt();
			Network.getInstance().connectToServer(tempIP, tempInt);
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		while(true){
			//Prints out all the commands available
			for (int i = cC.getListOfCommandsAvailable().size(); i > 0; i--){
				System.out.println(cC.getListOfCommandsAvailable().get(i-1));
			}
			
			//Prompts user
			System.out.println("ENTER COMMAND...");
			cC.executeCommand(sc.nextLine());
		}
		
		//Network.getInstance().close();
	}
}
